------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/gxzheng/Desktop/fintech/code/../log/finfigA5A11.log
  log type:  text
 opened on:  16 May 2023, 17:58:39

. 
. use ../data/KPSS_2019_public.dta, clear

. split issue_date, p("/")
variables created as string: 
issue_date1  issue_date2  issue_date3

. rename issue_date3 year

. destring year, replace
year: all characters numeric; replaced as int

. drop issue_date1 issue_date2

. keep if year > 2000
(1,380,955 observations deleted)

. save ../data/KPSS_after_2001.dta, replace
file ../data/KPSS_after_2001.dta saved

. 
. use ../data/financial_patent_data.dta, clear

. keep patent_id app_date grant_date

. rename patent_id patent_num

. merge 1:1 patent_num using "../data/KPSS_after_2001.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                     1,574,359
        from master                    14,632  (_merge==1)
        from using                  1,559,727  (_merge==2)

    Matched                             9,623  (_merge==3)
    -----------------------------------------

. drop if _m == 1
(14,632 observations deleted)

. 
. gen fin_pat = 1 if _m == 3
(1,559,727 missing values generated)

. replace fin_pat = 0 if _m == 2
(1,559,727 real changes made)

. drop _m

. 
. merge 1:1 patent_num using "../data/patent_cpc_class.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                     2,761,911
        from master                     1,295  (_merge==1)
        from using                  2,760,616  (_merge==2)

    Matched                         1,568,055  (_merge==3)
    -----------------------------------------

. keep if _m == 3
(2,761,911 observations deleted)

. replace cpc_class = "I" if fin_pat == 1
(9,623 real changes made)

. gen xi_95 = xi_real 

. gen cites_95 = cites

. collapse (mean) xi_real cites (p95) xi_95 cites_95, by(cpc_class year)

. gen log_xi_real = log(xi_real)

. gen log_cites = log(cites)

. gen log_xi_95 = log(xi_95)

. gen log_cites_95 = log(cites_95)
(18 missing values generated)

. 
. 
. * Figure A-5 Panel A
. twoway line log_xi_real year if cpc_class == "A", lw(medium) lc(midgreen) || ///
> line log_xi_real year if cpc_class == "B", lw(medium) lc(dkorange) || ///
> line log_xi_real year if cpc_class == "C", lw(medium) lc(sandb)|| ///
> line log_xi_real year if cpc_class == "D", lw(medium) lc(cyan) || ///
> line log_xi_real year if cpc_class == "E", lw(medium) lc(ebblue) || ///
> line log_xi_real year if cpc_class == "F", lw(medium) lc(lavender) || ///
> line log_xi_real year if cpc_class == "G", lw(medium) lc(stone) || ///
> line log_xi_real year if cpc_class == "H", lw(medium) lc(gray) || ///
> line log_xi_real year if cpc_class == "I", lw(medium) lc(red) || ///
> line log_xi_real year if cpc_class == "Y", lw(medium) lc(cranberry) xtitle("Issued Year", size(small)) ytitle("log of 
> Mean value of Kogan et al.(2017)", size(small)) ///
> legend(rows(5) symxsize(5) order(1 "Human Necessities" 2 "Transporting/Performing Operations" 3 "Chemistry/metallurgy"
>  4 "Textiles and paper" 5 "Fixed constructions" ///
> 6 "Mechanical engineering" 7 "Physics" 8 "Electricity" 9 "Finance" 10 "New Tech./Cross Tech.") size(small)) ///
> xlabel(2001(4)2018) graphregion(fcolor(white)) bgcolor(white)

. graph export "../Charts/Figure_A5A.png", replace
file /Users/gxzheng/Desktop/fintech/code/../Charts/Figure_A5A.png saved as PNG format

. 
. 
. 
. * Figure A-5 Panel B
. twoway line log_cites year if cpc_class == "A", lw(medium) lc(midgreen) || ///
> line log_cites year if cpc_class == "B", lw(medium) lc(dkorange) || ///
> line log_cites year if cpc_class == "C", lw(medium) lc(sandb)|| ///
> line log_cites year if cpc_class == "D", lw(medium) lc(cyan) || ///
> line log_cites year if cpc_class == "E", lw(medium) lc(ebblue) || ///
> line log_cites year if cpc_class == "F", lw(medium) lc(lavender) || ///
> line log_cites year if cpc_class == "G", lw(medium) lc(stone) || ///
> line log_cites year if cpc_class == "H", lw(medium) lc(gray) || ///
> line log_cites year if cpc_class == "I", lw(medium) lc(red) || ///
> line log_cites year if cpc_class == "Y", lw(medium) lc(cranberry) xtitle("Issued Year", size(small)) ytitle("log of Me
> an value of Kogan et al.(2017)", size(small)) ///
> legend(rows(5) symxsize(5) order(1 "Human Necessities" 2 "Transporting/Performing Operations" 3 "Chemistry/metallurgy"
>  4 "Textiles and paper" 5 "Fixed constructions" ///
> 6 "Mechanical engineering" 7 "Physics" 8 "Electricity" 9 "Finance" 10 "New Tech./Cross Tech.") size(small)) ///
> xlabel(2001(4)2018) graphregion(fcolor(white)) bgcolor(white)

. graph export "../Charts/Figure_A5B.png", replace
file /Users/gxzheng/Desktop/fintech/code/../Charts/Figure_A5B.png saved as PNG format

. 
. 
. 
. * Figure A-5 Panel C
. twoway line log_xi_95 year if cpc_class == "A", lw(medium) lc(midgreen) || ///
> line log_xi_95 year if cpc_class == "B", lw(medium) lc(dkorange) || ///
> line log_xi_95 year if cpc_class == "C", lw(medium) lc(sandb)|| ///
> line log_xi_95 year if cpc_class == "D", lw(medium) lc(cyan) || ///
> line log_xi_95 year if cpc_class == "E", lw(medium) lc(ebblue) || ///
> line log_xi_95 year if cpc_class == "F", lw(medium) lc(lavender) || ///
> line log_xi_95 year if cpc_class == "G", lw(medium) lc(stone) || ///
> line log_xi_95 year if cpc_class == "H", lw(medium) lc(gray) || ///
> line log_xi_95 year if cpc_class == "I", lw(medium) lc(red) || ///
> line log_xi_95 year if cpc_class == "Y", lw(medium) lc(cranberry) xtitle("Issued Year", size(small)) ytitle("log of to
> p 5th pct. of Kogan et al.(2017) value", size(small)) ///
> legend(rows(5) symxsize(5) order(1 "Human Necessities" 2 "Transporting/Performing Operations" 3 "Chemistry/metallurgy"
>  4 "Textiles and paper" 5 "Fixed constructions" ///
> 6 "Mechanical engineering" 7 "Physics" 8 "Electricity" 9 "Finance" 10 "New Tech./Cross Tech.") size(small)) ///
> xlabel(2001(4)2018) graphregion(fcolor(white)) bgcolor(white)

. graph export "../Charts/Figure_A5C.png", replace
file /Users/gxzheng/Desktop/fintech/code/../Charts/Figure_A5C.png saved as PNG format

. 
. 
. * Figure A-2 Panel D
. twoway line log_cites_95 year if cpc_class == "A", lw(medium) lc(midgreen) || ///
> line log_cites_95 year if cpc_class == "B", lw(medium) lc(dkorange) || ///
> line log_cites_95 year if cpc_class == "C", lw(medium) lc(sandb)|| ///
> line log_cites_95 year if cpc_class == "D", lw(medium) lc(cyan) || ///
> line log_cites_95 year if cpc_class == "E", lw(medium) lc(ebblue) || ///
> line log_cites_95 year if cpc_class == "F", lw(medium) lc(lavender) || ///
> line log_cites_95 year if cpc_class == "G", lw(medium) lc(stone) || ///
> line log_cites_95 year if cpc_class == "H", lw(medium) lc(gray) || ///
> line log_cites_95 year if cpc_class == "I", lw(medium) lc(red) || ///
> line log_cites_95 year if cpc_class == "Y", lw(medium) lc(cranberry) xtitle("Issued Year", size(small)) ytitle("log of
>  top 5th pct. of Citations(till 2019)", size(small)) ///
> legend(rows(5) symxsize(5) order(1 "Human Necessities" 2 "Transporting/Performing Operations" 3 "Chemistry/metallurgy"
>  4 "Textiles and paper" 5 "Fixed constructions" ///
> 6 "Mechanical engineering" 7 "Physics" 8 "Electricity" 9 "Finance" 10 "New Tech./Cross Tech.") size(small)) ///
> xlabel(2001(4)2018) graphregion(fcolor(white)) bgcolor(white)

. graph export "../Charts/Figure_A5D.png", replace
file /Users/gxzheng/Desktop/fintech/code/../Charts/Figure_A5D.png saved as PNG format

. 
. 
. 
. use ../data/financial_patent_data_v3.dta, clear

. 
. collapse (count) patent, by(app_year division)

. egen division_code = group(division)
(19 missing values generated)

. 
. gen app_period = 2004 if app_year >= 2000  & app_year <= 2004
(139 missing values generated)

. replace app_period = 2009 if app_year >=2005 & app_year <=2009
(50 real changes made)

. replace app_period = 2014 if app_year >= 2010 & app_year <= 2014
(50 real changes made)

. replace app_period  = 2018 if app_year >= 2015
(39 real changes made)

. 
. * Figure A-11
. eststo trend: reghdfe patent app_period##(b3.division_code), a(app_year) vce(robust)
note: 2009bn.app_period is probably collinear with the fixed effects (all partialled-out values are close to zero; tol =
>  1.0e-09)
note: 2014bn.app_period is probably collinear with the fixed effects (all partialled-out values are close to zero; tol =
>  1.0e-09)
note: 2018bn.app_period is probably collinear with the fixed effects (all partialled-out values are close to zero; tol =
>  1.0e-09)
(MWFE estimator converged in 1 iterations)
note: 2009.app_period omitted because of collinearity
note: 2014.app_period omitted because of collinearity
note: 2018.app_period omitted because of collinearity

HDFE Linear regression                            Number of obs   =        170
Absorbing 1 HDFE group                            F(  32,    119) =      92.75
                                                  Prob > F        =     0.0000
                                                  R-squared       =     0.9454
                                                  Adj R-squared   =     0.9224
                                                  Within R-sq.    =     0.9313
                                                  Root MSE        =    27.8620

------------------------------------------------------------------------------------------
                         |               Robust
               patent_id | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------------------+----------------------------------------------------------------
              app_period |
                   2009  |          0  (omitted)
                   2014  |          0  (omitted)
                   2018  |          0  (omitted)
                         |
           division_code |
                      1  |      -79.6   12.73973    -6.25   0.000    -104.8259   -54.37407
                      2  |     -160.2   9.965896   -16.07   0.000    -179.9335   -140.4665
                      4  |       -104   12.05584    -8.63   0.000    -127.8718   -80.12824
                      5  |      -98.4   11.76553    -8.36   0.000    -121.6969   -75.10308
                      6  |         11   12.72557     0.86   0.389    -14.19789    36.19789
                      7  |      -46.8   10.43826    -4.48   0.000    -67.46879   -26.13121
                      8  |     -132.6   10.76749   -12.31   0.000    -153.9207   -111.2793
                      9  |     -109.4   10.39791   -10.52   0.000    -129.9889    -88.8111
                         |
app_period#division_code |
                 2009 1  |       21.2   27.42746     0.77   0.441    -33.10912    75.50912
                 2009 2  |      -56.6    18.8292    -3.01   0.003     -93.8837    -19.3163
                 2009 4  |      -32.2   19.09506    -1.69   0.094    -70.01013    5.610129
                 2009 5  |      -43.6   16.72255    -2.61   0.010    -76.71231   -10.48769
                 2009 6  |       53.8   25.59115     2.10   0.038     3.126962     104.473
                 2009 7  |        7.8   16.13047     0.48   0.630    -24.13995    39.73995
                 2009 8  |      -32.2    17.6296    -1.83   0.070    -67.10838    2.708378
                 2009 9  |        -16   18.78024    -0.85   0.396    -53.18676    21.18676
                 2014 1  |       97.6   26.93488     3.62   0.000     44.26625    150.9337
                 2014 2  |        -45    25.1495    -1.79   0.076    -94.79852    4.798516
                 2014 4  |      -16.2   26.73576    -0.61   0.546    -69.13947    36.73947
                 2014 5  |       -8.2   25.82165    -0.32   0.751    -59.32944    42.92944
                 2014 6  |        230   36.48435     6.30   0.000     157.7573    302.2427
                 2014 7  |         43   25.84097     1.66   0.099    -8.167698     94.1677
                 2014 8  |        -22   24.35196    -0.90   0.368    -70.21931    26.21931
                 2014 9  |      -18.4   23.99168    -0.77   0.445    -65.90592    29.10592
                 2018 1  |     103.35   18.19334     5.68   0.000     67.32538    139.3746
                 2018 2  |   101.2417   20.91522     4.84   0.000     59.82744    142.6559
                 2018 4  |      93.25   15.66939     5.95   0.000     62.22305     124.277
                 2018 5  |       82.4   18.17013     4.53   0.000     46.42133    118.3787
                 2018 6  |     112.75   44.73188     2.52   0.013     24.17641    201.3236
                 2018 7  |       97.8      20.05     4.88   0.000       58.099     137.501
                 2018 8  |     109.35   18.19798     6.01   0.000     73.31617    145.3838
                 2018 9  |       92.9   17.79382     5.22   0.000     57.66647    128.1335
                         |
                   _cons |   169.3051   7.049044    24.02   0.000     155.3473     183.263
------------------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
    app_year |        19           0          19     |
-----------------------------------------------------+

. 
. coefplot (trend, keep(*.app_period#6.division_code) rename(*.app_period#6.division_code = .app_period_div) label("Paci
> fic") ciopts(recast(rarea) fcolor(navy*.2%75) lcolor(navy*.15 navy*.15 navy*.15) lwidth(thin) lpattern(solid solid sol
> id))) (trend, keep(*.app_period#7.division_code)  rename(*.app_period#7.division_code = .app_period_div) label("South 
> Atlantic") ciopts(recast(rarea) fcolor(maroon*.2%75) lcolor(maroon*.15 maroon*.15 maroon*.15) lwidth(thin) lpattern(so
> lid solid solid))),omitted baselevels levels(90) vertical nooffsets xlabel(1 "2000-2004" 2 "2005-2009" 3 "2010-2014" 4
>  "2015-2018") recast(connected) xtitle("Application Time Period") ytitle("Change in Number of Finance Patents") ylabel
> (0(100)300) yline(0) graphregion(color(white))

. graph export "../Charts/Figure_A11.png", replace
file /Users/gxzheng/Desktop/fintech/code/../Charts/Figure_A11.png saved as PNG format

. 
. log close
      name:  <unnamed>
       log:  /Users/gxzheng/Desktop/fintech/code/../log/finfigA5A11.log
  log type:  text
 closed on:  16 May 2023, 17:58:50
------------------------------------------------------------------------------------------------------------------------
